home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 026a / j1_xtab.zip / JP1_XTAB.DOC < prev    next >
Text File  |  1990-09-23  |  7KB  |  123 lines

  1.                 Documentation for JP1_XTAB.PRG
  2.  
  3. Purpose:        Extend crosstab() with three operations, AVG, STD and VAR,
  4.                 and by adding summary row and column.
  5.  
  6. Author:         Original crosstab code by Bill Ramos and Kirk Nason,
  7.                 copyright by Ashton-Tate.
  8.                 Modified by Jay Parsons, CIS 70160,340, AT-BBS Jparsons
  9.                 Modifications are copyrighted; see .PRG file for license.
  10.  
  11. Version:        1.0 <grin>.
  12. Date:           September 23, 1990.
  13.  
  14. *-----------------------------------------------------------------------------
  15.  
  16.                         Special Note
  17.  
  18.         If you don't have the Control Center Booster, you will NOT be able to
  19. use the attached file JP1_XTAB.PRG.  If you do have the booster, BACK IT UP.
  20. Then delete from it all the code for these three items:
  21.  
  22.                 FUNCTION crosstab()
  23.                 PROCEDURE XT_DisGets
  24.                 PROCEDURE Com_Xtab
  25.  
  26.         Append the JP1_ZTAB.PRG file to the truncated CCBOOSTR.PRG file.  Then
  27. start dBASE, compile and activate the amended file by "SET PROC TO CCBOOSTR"
  28. (or, if you have prudently given the amended file another name, SET PROC TO
  29. <its name>, and type ASSIST to use it.  Activate CAMPING.DBF or another file,
  30. move to the Query column and choose CREATE, and type "crosstab()" into any
  31. column but the first "filename pothandle."
  32.  
  33.         Like the original code, this code leaves you with files selected and
  34. open other than the ones originally selected.  The 8-record file CAMPING.DBF
  35. is included for testing, etc.
  36.  
  37. *----------------------------------------------------------------------------
  38.  
  39.                         Description of modifications
  40.  
  41.         The modifications made are of two distinct sorts; the code is rather
  42. roughly commented to indicate which parts may be removed if it is desired to
  43. remove one or the other of the modifications.
  44.  
  45.         The first modification is to support the functions AVG, STD and VAR,
  46. representing the average, population standard deviation and population variance
  47. of the items tabulated in addition to the original SUM, CNT, MAX and MIN.  I am
  48. not a statistician and do not know whether the sample deviation and variance
  49. would be more meaningful measures of dispersion of the cross-tabulated groups;
  50. if so will anyone knowing that to be the case please notify me.  In any event,
  51. changing these requires simply subtracting 1 from the denominator of the
  52. formula used to calculate the variance (the final denominator, not the internal
  53. division of the square of the sum of the values.)
  54.  
  55.         The formula used for variance is:
  56.  
  57.         ( Sum of squares of items less
  58.         ( square of sum of items / number of items ) )
  59.         all divided by number of items.      && s.b.- 1 for sample statistics.
  60.  
  61.         And, of course, std = sqrt( var ).
  62.  
  63.         For simplicity, the extended functions report a 0 value where there
  64. are no members of the detail crosstabulated group ("cell").  That is, in the
  65. enclosed Camping file Jane does not buy a Stove, so there is nothing in the
  66. cell where the row "Jane" intersects the column "Stove".  None of the statistics
  67. AVG, STD and VAR are meaningful, so a 0 is output to the Crosstab.dbf file.
  68.  
  69.         This creates a problem.  In the Camping file, Jane buys only one Tent.
  70. Since there is no variance or standard deviation among one item, a zero also
  71. appears here in the Crosstab file if these operations are chosen.  However,
  72. since Jane has bought three items in all, the summary column properly reflects
  73. the standard deviation or variance among the prices of all three items.  This
  74. looks incorrect, because the summary column will contain a figure quite
  75. unrelated to the figures visible in the detail cells.  I know of no way to
  76. remove this peculiarity other than to copy all the values to a file of all-
  77. character fields, replace the zeroes with "N/A" where there are no members,
  78. and perhaps also include the number of members in each group with it.  This
  79. has NOT been done in the interest of preserving the original structure of
  80. one displayed number per cell.  Removing the support for summary rows and
  81. columns will make the output look less goofy, but will not eliminate the
  82. possible confusion between a "0" meaning one item and no dispersion and a "0"
  83. meaning no data.
  84.  
  85.         To support the additional operations, up to two files, N_XTAB.DBF and
  86. SQ_XTAB.DBF, are created (or will be overwritten) for operations that need
  87. them.  STD and VAR need both, AVG only N_XTAB.  These files hold the numbers
  88. (N_XTAB) of members in a cell or the sum of the squares of the members
  89. (SQ_XTAB), both figures being needed for the statistical calculations.  Also
  90. created are one or two arrays with as many elements as the number of columns
  91. plus two, which may push memory to the limit (try reducing dBheap, particularly
  92. if you have a cache.)  These are used to hold the "downward" totals of the
  93. various columns of the other files.
  94.  
  95.         As indicated above, the figures in the "Summary" row and column are
  96. calculated using all members of the row or column, ignoring cells with no
  97. members; they are not simply the sum, average, etc. of the figures in the
  98. cells.
  99.  
  100.         The second modification is the addition of a row and a column to the
  101. crosstab table to hold the summaries.  This modification is theoretically
  102. independent of the support for additional operations and can be removed from
  103. the code independently, although the effort to do everything in a single pass
  104. causes commingling in the source code of the modifications.  To comply with
  105. the convention in the original code of arranging rows and columns in order
  106. of the sort order of their fieldnames, the summary row and column are given
  107. working names of "Z_____", the last possible fieldname, which is replaced at
  108. display time with "Summary".  The need to change the name without changing the
  109. display order requires the addition of one additional field to Crosstab.dbf
  110. holding the record number in display order.
  111.  
  112.         As implemented, the "Summary" row or column gives the same statistic
  113. as the other cells, applied to the members of its row or column or, in case of
  114. the lowest and rightmost cell, to the whole file.  That is, if MAX is chosen as
  115. the operation, the maximum of each row will appear in the summary column to the
  116. right, the maximum of each column at its foot, and the maximum of the values in
  117. the entire file at lowest right.  Similarly, STD will report the standard
  118. deviations of the members of the cells in its row, column or file.  Anyone
  119. who feels this behavior is not appropriate is invited to call me in the
  120. interest of developing a program that does what it should.
  121.  
  122.         Jay Parsons
  123.